<template>
  <el-container>
    <el-header style="border-bottom: 1px solid rgba(255,255,255,0.12)">
      <p style="font-family: MicrosoftYaHei;font-size: 16px;color: #7DDAFF;">停车场信息</p>
    </el-header>
    <el-main>
      <el-row class="btn-group">
        <el-button class="btn" @click="handleDownloadParkInfo">
          <span>导出</span><i class="el-icon-download"></i>
        </el-button>
      </el-row>

      <el-table :data="dataList" v-loading="listLoading" element-loading-text="给我一点时间"
                :row-class-name="tableRowClassName"
                height="500"
                element-loading-background="rgba(0, 0, 0, .3)"
                style="width: 100%;padding-top: 0px;background-color: #1B4685" ref="parkInfoTable">
        <el-table-column align="center" label="车牌号" prop="plateNo" width="150">
          <template slot-scope="scope">
            <span v-if="scope.row.plateColor === 2"
                  style="display:block;background-color: #1890FF;text-align: center;color: #FFFFFF;width: 120px">
              {{scope.row.plateNo}}</span>

            <span v-if="scope.row.plateColor === null"
                  style="background-color: #2276d2;color: #FFFFFF;display:block;text-align: center;width: 120px">
              {{scope.row.plateNo}}</span>

            <span v-if="scope.row.plateColor === 1"
                  style="background-color: yellow;color: black;display:block;text-align: center;width: 120px">
              {{scope.row.plateNo}}</span>

            <span v-if="scope.row.plateColor === 4"
                  style="background-color: #418038;color: #FFFFFF;display:block;text-align: center;width: 120px">
              {{scope.row.plateNo}}</span>

            <span v-if="scope.row.plateColor === 0"
                  style="background-color: #FFF;color: #000;display:block;text-align: center;width: 120px">
              {{scope.row.plateNo}}</span>
          </template>
        </el-table-column>
        <el-table-column align="center" label="车场名称" sortable prop="parkName">
          <template slot-scope="scope">
            <span>{{scope.row.parkName}}</span>
          </template>
        </el-table-column>
       <!-- <el-table-column align="center" label="出入场设备编号" sortable prop="parkName">
          <template slot-scope="scope">
            <span>{{scope.row.deviceNum}}</span>
          </template>
        </el-table-column>-->
        <el-table-column align="center" label="停车场编号" sortable prop="parkName">
          <template slot-scope="scope">
            <span>{{scope.row.parkNo}}</span>
          </template>
        </el-table-column>
        <el-table-column v-if="!model" align="center" label="入场时间" sortable prop="equipmentVender" width="200">
          <template slot-scope="scope">
            <span>{{scope.row.inTime}}</span>
          </template>
        </el-table-column>
        <el-table-column v-if="!model" align="center" label="出场时间" sortable prop="equipmentVender" width="200">
          <template slot-scope="scope">
            <span>{{scope.row.outTime}}</span>
          </template>
        </el-table-column>
        <!--<el-table-column align="center" label="行政区" sortable prop="parkName">
          <template slot-scope="scope">
            <span>{{scope.row.district}}</span>
          </template>
        </el-table-column>
        <el-table-column align="center" label="经营单位" sortable prop="parkName">
          <template slot-scope="scope">
            <span>{{scope.row.parkOrg}}</span>
          </template>
        </el-table-column>-->
        <el-table-column align="center" label="记录编号" sortable prop="parkName">
          <template slot-scope="scope">
            <span>{{scope.row.recordNo}}</span>
          </template>
        </el-table-column>
        <!--<el-table-column align="center" label="出入场类型" prop="equipmentVender" width="150">-->
          <!--<template slot-scope="scope">-->
            <!--<span>{{scope.row.inOrOut === 1?'入场':'出场'}}</span>-->
          <!--</template>-->
        <!--</el-table-column>-->

        <el-table-column fixed="right" align="center" label="操作" width="120">
          <template slot-scope="scope">
                <span class="btn-group">
            <el-button class="four-btn" style=" margin-bottom: 0px"
                       @click="handleDetail(scope.row)"><span>照片</span><i class="el-icon-edit-outline"></i>
            </el-button>
                </span>
          </template>
        </el-table-column>
      </el-table>

    </el-main>
    <el-footer>
      <el-pagination style="margin-top: 16px" background
                     @size-change="handleSizeChangeParkInfo"
                     @current-change="handleCurrentChangeParkInfo"
                     :current-page="listQuery.page"
                     :page-sizes="[10,20,30, 50]"
                     :page-size="listQuery.limit"
                     layout="total, sizes, prev, pager, next, jumper" :total="total">
      </el-pagination>
    </el-footer>
    <el-dialog title="照片" :visible.sync="detailVisible" center width="620px">
      <div v-if="!model" style="text-align: center">
        <el-tag type="danger" v-if="tempParkInfo.inImg == null">暂无入场信息</el-tag>
        <el-container v-if="tempParkInfo.inImg != null">
          <el-main style="text-align: center;margin: 0">
            <h3 style="margin: 0 auto;color: white;">入场信息</h3>
              <img v-if="tempParkInfo.inImg != null" style="width: 80%;height: 250px;" :src='"images/"+tempParkInfo.inImg'/>
          </el-main>
        </el-container>
        <el-tag type="danger" v-if="tempParkInfo.outImg == null">暂无出场信息</el-tag>
        <el-container v-if="tempParkInfo.outImg != null">
          <el-main  style="text-align: center;margin: 0">
            <h3 style="margin: 0 auto;color: white;">出场信息</h3>
              <img v-if="tempParkInfo.outImg != null"  style="width: 80%;height: 250px;" :src='"images/"+tempParkInfo.outImg'/>
          </el-main>
        </el-container>
      </div>
    <br/>
    </el-dialog>
  </el-container>
</template>

<script>
  /* eslint-disable */

  export default {
    name: "park-info-table",
    props: ['searchList', 'listLoadingParkInfo', 'showModel'],
    watch: {
      searchList(val) {
        this.dataList = val.list
        this.total = val.count
      },
      listLoadingParkInfo(val) {
        console.log('val', val)
        this.listLoading = val
      },
      showModel(val) {
        this.model = val
      }
    },
    data() {
      return {
        listLoading: false,
        detailVisible: false,
        dataList: [],
        total: 0,
        listQuery: {
          page: 1,
          limit: 20
        },
        model: false,
        tempParkInfo: {},
        imgUrl: 'http://img2.imgtn.bdimg.com/it/u=1629300826,4257003656&fm=27&gp=0.jpg'
      }
    },
    methods: {
      handleDownloadParkInfo() {
      },
      handleSizeChangeParkInfo(val) {
        this.$emit("handleSizeChangeParkInfo", val)
      },
      handleCurrentChangeParkInfo(val) {
        this.$emit("handleCurrentChangeParkInfo", val)
      },
      handleDetail(row) {
        this.tempParkInfo = row
        this.detailVisible = true
      },
      tableRowClassName({ row, rowIndex }) {
        if (rowIndex % 2 === 0) {
          return 'one-row';
        } else {
          return '';
        }
      }
    }
  }
</script>

<style scoped>
  .btn-group > .el-button span {
    display: none;
  }

  .btn-group > .el-button:hover {
    background-color: #409EFF;
  }

  .btn-group > .el-button:hover span {
    display: block;
  }

  .btn-group > .el-button:hover i {
    display: none;
  }

  .el-dialog--center .el-dialog__body{
    text-align: center;
  }
</style>
